﻿@using U1City.UPos.Server.DataTransferObject.Shop
@using U1City.UPos.Server.UI.QueryAndExport.Order
@{
    ViewBag.Title = "OfflineShopSaleOrdersQuery";
    Layout = "~/Views/Shared/_Layout.cshtml";

    
    //配置导出的入口
    string exportPortal = typeof(OrderExport).FullName;
}

<script src="@Url.Path("Resources/Plugins/DatePicker/WdatePicker.js")" charset="gbk"></script>

<div id="gd">
</div>
<div class="searchBar" id="searchbar">
    <ul>
        
        <li>
            <span class="title">时间段：</span>
            <input type="text" value="@(String.Format("{0:yyyy-MM-dd 00:00:00}",DateTime.Now))" col="StartTime" field="StartTime" onfocus="WdatePicker({isShowClear:false,dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true})"/>-
            <input type="text" value="@(String.Format("{0:yyyy-MM-dd HH:mm:ss}",DateTime.Now))" col="EndTime" field="EndTime" onfocus="WdatePicker({isShowClear:false,dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true})"/>
        </li>
        <li><span class="title">门店名称：</span>
            <select col="ShopID" field="ShopID">
                <option value="">全部门店</option>
                @foreach (OfflineShopDTO shop in ViewBag.Shops)
                {
                    <option value="@shop.ID">@shop.ShopName</option>
                }
            </select>
        </li>
        <li><span class="title">订单号：</span>
            <input type="text" col="OrderNo" field="OrderNo"/></li>

    </ul>
</div>

<div class="totalView" id="totalView">
    订单销售总数:<span field="OrderNum">-</span>
    销售总数量：<span field="SaleGoodsNum">-</span>
</div>

<div class="toolBar">
    <table>
        <tr>
            <td>
                <a class="easyui-linkbutton"  id="btnExport">导出</a>
            </td>
        </tr>
    </table>
</div>

<script src="@Url.Path("QueryAndExport/expr.js")"></script>
<script>
    expr.ele = 'searchbar';
    expr.portal = '@exportPortal';
    expr.checkParams = function (data) {
        return true;
    };

    var Search = function() {expr.search('gd');};
    var refresh =function(){expr.reload('gd');};

    $(function () {

        //导出
        $('#btnExport').click(
            function() {
                 expr.showExportDialog();
            });

        //编辑
        window.showDetail = function (id) {
            openPage('查看订单详情','@Url.Path("MerchantQuery/ShowOrderDetail?source=OfflineShop&orderNo=")' + id);
            //PW.getWindow("ShowOrderDetail?source=OfflineShop&orderNo=" + id, "查看订单详情", 600, 400);
        };


        //格式化操作
        window.opFormat = function (value, row) {
            return "<a href=\"javascript:void(0)\" onclick=\"showDetail('" + row.ID + "')\">详情</a>";
        };

        //加载数据
        $('#gd').U1EasyGrid({
            singleSelect: false,
            url: expr.getDataUrl(),
            columns: [[
                { field: 'ck', title: '选择', checkbox: true },
                { field: 'OrderNo', title: '订单号', sortable: true, align: 'center', width: 150 },
                { field: 'ShopName', title: '门店名称', sortable: true, align: 'center', width: 150 },
                { field: 'SaleDate', title: '销售日期', sortable: true, align: 'center', width: 150 },
                { field: 'SaleTime', title: '销售时间', sortable: true, align: 'center', width: 150 },
                { field: 'TotalNum', title: '销售数量', sortable: true, align: 'center', width: 150 },
                { field: 'op', title: '详情', align: 'center', width: 100, formatter: opFormat }
            ]]
        });

        //统计汇总数量
        expr.bindTotalView('totalView');
    });



</script>

